package com.pinapel.aixml.ui.actions;

import java.io.File;

import javax.swing.filechooser.FileFilter;

import com.pinapel.aixml.tools.FileManager;

public class ImageFilter extends FileFilter{
    private final static String jpeg = "jpeg";
    private final static String jpg = "jpg";
    private final static String gif = "gif";
    private final static String tiff = "tiff";
    private final static String tif = "tif";
    private final static String png = "png";
    
	@Override
	public boolean accept(File file) {
		   //Accept all directories and all gif, jpg, tiff, or png files.
	        if (file.isDirectory()) {
	            return true;
	        }

	        String extension = FileManager.getExtension(file);
	        if (extension != null) {
	            if (extension.equals(tiff) ||
	                extension.equals(tif) ||
	                extension.equals(gif) ||
	                extension.equals(jpeg) ||
	                extension.equals(jpg) ||
	                extension.equals(png)) {
	                    return true;
	            } else {
	                return false;
	            }
	        }

	        return false;
	}

	@Override
    /**
     * The description of this filter
     */
	public String getDescription() {
		// TODO Auto-generated method stub
		return "Just Images";
	}

}
